<?php
$this->breadcrumbs=array(
	'Payout Report',
);

if ( !isset($_GET['year']) ) {
  $p_year = date("Y"); 	
}
else  {
  $p_year = $_GET['year'];	
}
?>

<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl;?>/assets/4d2e049c/gridview/styles.css" />
<h1>Payout Summary</h1>
<form method="get">
    Select Year:
	<select name="year">
		<?php 
		  $year_start = 2012;
          $year_now = date("Y");
          $year = $year_now;
		  while ( $year >= $year_start ) { 
		  	 if ( $year == $p_year) {?>		
		        <option value="<?php echo $year?>" selected="selected"> <?php echo $year?></option>
		     <?php } else { ?>
		     	<option value="<?php echo $year?>"> <?php echo $year?></option>
		     <?php } ?>
		<?php $year--; }?>
	</select>
	<input type="submit" value="Get Report" /> &nbsp; &nbsp; Click the total payout amount to download breakdown.
</form>

<div class="grid-view">
	<table class="items">
		<tr>
			<th>Year</th><th>Month </th> <th>Total BV </th><th> Total Payout </th>
		</tr>
	<?php 
	    $class = "odd";
	    foreach ( $payout_data as $data) {
	    	$monthName = date("F", mktime(0, 0, 0, $data['month_no'], 10));
		?>
			<tr class="<?php echo $class?>">
				<td align="center"> <?php echo $data['year']?> </td>
				<td align="center"> <?php echo $monthName?> </td>
				<td align="right"> <?php echo number_format($data['total_bv'])?> </td>
				<td align="right"> 
					<a href="<?php echo Yii::app()->request->baseUrl;?>?r=PayoutReport/excelPayouts&w=<?php echo $data['month_no']?>&y=<?php echo $data['year']?>">P <?php echo number_format($data['total_payout'],2)?> </a>
			    </td>
			</tr>
	<?php 
			if ( $class=='odd' )
		        $class = 'even';
		    else
		        $class = 'odd';
		} ?>
	</table>
</div>